﻿Public Class update_control

    WithEvents download As New System.Net.WebClient
    WithEvents download_upd As New System.Net.WebClient
    Dim file_testo As String = "http://drawsearch.googlecode.com/files/Drawsearch_version_Update.txt"
    Dim indirizzo_aggiornamento As String
    Dim versione_corrente As String
    Dim versione_update As String
    Dim download_completato = 0
    Dim download_upd_completato = 0


    Property version_application As String

    Public Shared Sub CONTROLLO_AGGIORNAMENTI()
        Dim LISTAFILE As New ArrayList
        Dim FILEINFO_SERVER As System.IO.FileInfo
        Dim DATA_LOCALE As Object
        Dim LENGHT_LOCALE As Object
        Try
            For Each FILE In My.Computer.FileSystem.GetFiles("\\LAFER2K3\Uff_tec\PDF_PROE\Drawsearch_host", FileIO.SearchOption.SearchTopLevelOnly, "*.*")
                Dim FILEINFO = My.Computer.FileSystem.GetFileInfo(FILE)
                Dim NOMEFILE = My.Computer.FileSystem.GetName(FILE)
                Dim DATA = FILEINFO.LastWriteTimeUtc
                Dim LENGHT = FILEINFO.Length

#If DEBUG Then
                If My.Computer.FileSystem.FileExists("\\LAFER2K3\Uff_tec\PDF_PROE\Application Files\Drawsearch_host\" & NOMEFILE) Then
                    FILEINFO_SERVER = My.Computer.FileSystem.GetFileInfo("\\LAFER2K3\Uff_tec\PDF_PROE\Application Files\Drawsearch_host\" & NOMEFILE)
                    DATA_LOCALE = FILEINFO_SERVER.LastWriteTimeUtc
                    LENGHT_LOCALE = FILEINFO_SERVER.Length
                End If
#Else
                If My.Computer.FileSystem.FileExists(Application.StartupPath & "\" & NOMEFILE) Then
                    FILEINFO_SERVER = My.Computer.FileSystem.GetFileInfo(Application.StartupPath & "\" & NOMEFILE)
                    DATA_LOCALE = FILEINFO_SERVER.LastWriteTimeUtc
                    LENGHT_LOCALE = FILEINFO_SERVER.Length
                End If
#End If

                If DATA > DATA_LOCALE Or DATA > DATA_LOCALE Then
                    'If LENGHT_LOCALE < LENGHT Or LENGHT_LOCALE > LENGHT Then
                    LISTAFILE.Add(NOMEFILE)
                    'End If
                End If
            Next
        Catch EX As Exception
        End Try

        Dim STREAM As Object
        If LISTAFILE.Count > 0 Then
#If DEBUG Then
            STREAM = New System.IO.StreamWriter("\\STAZIONE_D5\DrawSearch Suite for Lafer\Temp\filedaaggiornare")
#Else
            STREAM = New System.IO.StreamWriter(Application.StartupPath & "\Temp\filedaaggiornare")
#End If

            For Each item In LISTAFILE
                STREAM.WriteLine(item)
            Next
            STREAM.Close()
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CONTROLLO_AGGIORNAMENTI()
    End Sub
End Class
